#ifndef __FOXterrier__
#define __FOXterrier__

#include <fx.h>
#include <fx3d.h>

#include "core/Core.h"
#include "core/iEnvExporter.h"

using neiderra::core::Core;
using neiderra::core::iEnvExporter;

class FOXterrier: public FXMainWindow, public iEnvExporter
{
	FXDECLARE(FOXterrier)
protected:
	// default constructor (see FOX documentation)
	FOXterrier() {}
public:
	FOXterrier(FXApp*);
	virtual ~FOXterrier();

	void create();

	enum {
		ID_TEST = FXMainWindow::ID_LAST,
		ID_CANVAS,
		ID_SWITCHER,
		ID_CONSOLE,
		ID_LOG,

		ID_MENU_CORE_POWERUP,
		ID_MENU_CORE_SHUTDOWN,
		ID_MENU_CORE_SUSPEND,
		ID_MENU_CORE_RESUME,
		ID_MENU_CORE_ENV_SENDCMD,
		ID_MENU_HELP_ABOUT,
		ID_MENU_VIEW_CONSOLE,
		ID_MENU_OPTIONS_SAVESETTINGS,

		ID_INTERRUPT,
		ID_SELF_UPDATE,
		ID_LAST 
	};

	long onSelfUpdate(FXObject*,FXSelector,void*);

	long onMenuHelpAbout(FXObject*,FXSelector,void*);
	long onMenuViewConsole(FXObject*,FXSelector,void*);
	long onMenuCorePowerup(FXObject*,FXSelector,void*);
	long onMenuCoreSuspend(FXObject*,FXSelector,void*);
	long onMenuCoreResume(FXObject*,FXSelector,void*);
	long onMenuCoreShutdown(FXObject*,FXSelector,void*);
	long onMenuCoreEnvSendCmd(FXObject*,FXSelector,void*);
	long onMenuOptionsSaveSettingsCmd(FXObject*,FXSelector,void*);
	
	long onCanvasLeftMouseClicked(FXObject*,FXSelector,void*);

	long onExpose(FXObject*,FXSelector,void*);
	long onConfigure(FXObject*,FXSelector,void*);
	long onConsoleCmd(FXObject*,FXSelector,void*);
	long onLogCmd(FXObject*,FXSelector,void*);
	long onConsoleKeyPressed(FXObject*,FXSelector,void*);
	long onCleanUpAndQuit(FXObject*,FXSelector,void*);
	
	//
	// iEnvExporter interface
	//
	virtual void executeMethod(const string& name, const list<string>& args );
	virtual void exportMembers();

protected:
	// initializes controls
	void initControls();
	// initializes menus
	void initMenu();
	// initializes subsystems
	void initSubsystems();
	// shutdown subsystems
	void shutdownSubsystems();

	Core* getCore() { return _core; }

	void setStatusMsg(const string&);

protected:
    FXMenuPane	*_fileMenu, 
				*_editMenu,
				*_coreMenu,
				*_coreEnvMenu,
				*_viewMenu,
				*_optionsMenu,
				*_helpMenu;

	FXStatusBar*	_statusBar;
	FXTabBook*		_tabBook;
	FXTabItem*		_tab1;
	FXTabItem*		_tab2;
	FXComposite*	_contents;
	FXHorizontalFrame*	_workFrame;
	FXVerticalFrame*	_logFrame;
	FXGLCanvas	*_glcanvas;                  // GL Canvas to draw into
	FXGLVisual	*_glvisual;
	FXList		*_logList;
	FXTextField	*_txtfConsole;
	//FXComboBox	*_txtfConsole;

	Core* _core;
};

#endif
